//package cn.chaconne.timesystem.commons.exception;
//
//import cn.chaconne.timesystem.commons.enums.ResponseCode;
//import cn.chaconne.timesystem.commons.model.ResponseData;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.validation.BindingResult;
//import org.springframework.validation.FieldError;
//import org.springframework.web.bind.MethodArgumentNotValidException;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.List;
//
///**
// * 全局异常处理
// *
// * @author liang.wang
// * @Filename GlobalExceptionHandler.java
// * @description
// * @Version 1.0
// */
//@ControllerAdvice
//@ResponseBody
//@Slf4j
//public class GlobalExceptionHandler {
//
//	/**
//	 * validate 验证错误handle
//	 *
//	 * @param request
//	 * @param exception
//	 * @return
//	 * @throws Exception
//	 */
//	@ExceptionHandler(value = Exception.class)
//	public Object bindExceptionHandler(HttpServletRequest request, Exception exception) {
//		ResponseData result = new ResponseData<>();
//		if (exception instanceof BusinessException) {
//			BusinessException e = (BusinessException) exception;
//			result = new ResponseData(ResponseCode.BUSINESS_EXCEPTION, e.getMessage());
//
//		} else if (exception instanceof MethodArgumentNotValidException) {
//			MethodArgumentNotValidException exp = (MethodArgumentNotValidException) exception;
//			BindingResult bindingResult = exp.getBindingResult();
//			List<FieldError> fieldErrors = bindingResult.getFieldErrors();
//			result = new ResponseData(ResponseCode.PARAM_EXCEPTION, fieldErrors.get(0).getField() + "" + fieldErrors.get(0).getDefaultMessage());
//		} else {
//			result = new ResponseData(ResponseCode.SYSTEM_EXCEPTION, "系统繁忙，请稍后再试");
//		}
//		return result;
//	}
//}
